#include <iostream>
#include <memory>
#include <vector>
using namespace std;
void test(){
    unique_ptr<int> up(new int(10));
    //unique_ptr<int> up2 = up;//拷贝构造函数error
   //右操作数所托管的指针变为空指针
   //左操作数接收指针
    unique_ptr<int> up3 = std::move(up);
    cout<< up3.get()<<endl;
    cout << up.get() <<endl;
}
class Point{
public:
    Point(int x ,int y)
    :_x(x)
    ,_y(y)
    {

    }
    void print(){
        cout << _x << "," << _y <<endl;
    }
private:
    int _x;
    int _y;
};
void test2(){
    unique_ptr<Point> up(new Point(1,2));
    vector<unique_ptr<Point>> vec;
    vec.push_back(std::move(up));
    //vec.push_back(up);此时的up已经为空指针了
}
void test3(){
    unique_ptr<Point> up(new Point(1,2));
    vector<unique_ptr<Point>> vec;
    vec.push_back(std::move(up));
    //会把Point(3,4)的控制权交给vec里面创建的up
    vec.push_back(unique_ptr<Point>(new Point(3,4)));
}
int main()
{
    test3();
    return 0;
}

